package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Student_competition;
import com.example.Laboratory.Service.Student_competitionService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@Api(value = "Student_competition", description = "学生竞赛表")
@RestController
@RequestMapping(value = "/Student_competition")
@CrossOrigin
public class Student_competitionController {
    @Autowired
    Student_competitionService student_competitionService;

    @ApiOperation(value = "添加学生竞赛信息", notes = "添加学生竞赛信息")
    @RequestMapping(value = "/addStudent_competition", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addStudent_competition (Student_competition s) throws IOException {
        return ResultCode.SUCCESS.result(student_competitionService.addStudent_competition(s));
    }

    @ApiOperation(value = "删除学生竞赛信息", notes = "删除学生竞赛信息")
    @RequestMapping(value = "/deleteStudent_competition", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteTrain (@RequestParam int student_competition_id) throws IOException {
        return ResultCode.SUCCESS.result(student_competitionService.deleteStudent_competition(student_competition_id));
    }

    @ApiOperation(value = "查找学生竞赛信息", notes = "查找学生竞赛信息")
    @RequestMapping(value = "/researchStudent_competition", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchTrain ( ) throws IOException {
        return ResultCode.SUCCESS.result(student_competitionService.researchStudent_competition());
    }

    @ApiOperation(value = "修改学生竞赛信息", notes = "修改学生竞赛信息")
    @RequestMapping(value = "/reviseStudent_competition", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseTrain (Student_competition s) throws IOException {
        return ResultCode.SUCCESS.result(student_competitionService.reviseStudent_competition(s));
    }
}
